/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ania2.gui;

import java.awt.Color;
import java.awt.Component;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

/**
 *
 * @author pawel
 */
public class TableHeaderCellRenderer extends JPanel implements TableCellRenderer {

    public TableHeaderCellRenderer() {
        super();
        setOpaque(true);
    }


    public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column) {
        setBackground(new Color(238, 238, 238));

        //setText((value == null) ? "" : value.toString());
        return this;
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) g;
        Point p1 = new Point(this.getWidth()/2, 0);
        Point p2 = new Point(this.getWidth()/2, this.getHeight());
        g2.setPaint(new GradientPaint(p1, Color.red, p2, Color.white));
        g2.fillRect(0, 0, this.getWidth(), this.getHeight());

    }


}
